"use strict";
/**
 * @name dayChange
 * 跨天刷新
 */



/**
 * @name /
 * 跨天刷新
 */

module.exports = async function () {

    this.updater.role.key('login', 'sumlog', 'conlog', 'time');
    await this.updater.data();

    let lastTime = this.updater.role.get('login') || 0;
    let todayTime = this.library("time/today");
    let now = Date.now();
    this.updater.role.set("login", now);
    if (lastTime >= todayTime) {

    } else {
        //============================日常数据==================================
        let sumlog = this.updater.role.get('sumlog') || 0;
        let conlog = this.updater.role.get('conlog') || 0;
        this.updater.role.set('sumlog', sumlog + 1);
        let yesterday = todayTime - 86400 * 1000;
        if (lastTime >= yesterday) {
            this.updater.role.set('conlog', conlog + 1);
        }
        else {
            this.updater.role.set('conlog', 1);
        }
        //DAU统计
        this.library("spirit/gzone", '/dau/', { "sid": this.sid, "time": this.updater.role.get('time') }).catch(err => {
            console.log("spirit/gzone", "/dau/", err)
        })
        this.updater.daily.set("record." + "11", 1);
        this.updater.daily.set("login", 1);
        this.updater.record.add(11, 1);
    }
    return this.updater.save();
};  